 **** Replication script for The Origin of Social Policy for Women Workers: The Emergence of Paid Maternity Leave in Western Countries ****
 **** Author: Keonhi Son ****
 **** Stata version:  17.0 SE—Standard Edition ****
 
 clear 
 set more off
 import excel "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\women_sp2.xlsx", sheet("Sheet 1") firstrow
  
 gen gdppc = log(gpdpc)
 xtset ccode year
 global avars "gender gender_cs gender_cl w_in_par suffrage wp_experience long_tfr party2 gdppc polity polity2 pr War_Index2 protective"

foreach var of varlist $avars {
	gen Lag`var' = l.`var'
}

 drop if year > 1974

 stset year, failure(introduction == 1) id(ccode) origin(enter == 1)
 stgen nf = nfailures()
 stsum, by(nf)
 
 gen d = _d
 gen t = _t
 gen log_t = log(_t)
 
 **** Table 2. Multivariate analysis, Weibull model ****  
 eststo: streg c.Lagw_in_par c.wp_experience, distribution(weibull) vce(robust)
 estimates store stcox1
 eststo: streg c.sum c.wp_experience, distribution(weibull) vce(robust)
 estimates store stcox1
 estat vce, corr
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr  protective ilo_mem i.depression suffrage c.sum sick_yearlaw, d(weibull) vce(robust)
 estimates store stcox2
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr protective ilo_mem i.depression suffrage c.sum, d(weibull) vce(robust)
 estimates store stcox3
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr protective ilo_mem i.depression suffrage c.sum wp_experience, d(weibull) vce(robust)
 estimates store stcox4
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr protective ilo_mem i.depression suffrage c.Lagw_in_par c.wp_experience, d(weibull) vce(robust)
 estimates store stcox5
 outreg2 [stcox3 stcox2 stcox4 stcox5] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\Women_stcox.doc", replace 
 
 **** Appendix 3. Robustness check: inclusion of other social policies **** 
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr  protective ilo_mem i.depression suffrage c.sum oldage_yearlaw, d(weibull) vce(robust)
 estimates store robust1
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr  protective ilo_mem i.depression suffrage c.sum unemp_law, d(weibull) vce(robust)
 estimates store robust2
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr  protective ilo_mem i.depression suffrage c.sum family_yearlaw, d(weibull) vce(robust)
 estimates store robust3
 eststo: streg gdppc long_tfr i.party2 Lagpolity Lagpr  protective ilo_mem i.depression suffrage c.sum working_yearlaw, d(weibull) vce(robust)
 estimates store robust4
 outreg2 [robust1 robust2 robust3 robust4] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\robust_check_othersocialpolicies.doc", replace

 clear
 set more off
 import excel "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\women_sp.xlsx", sheet("Sheet 1") firstrow

 gen gdppc = log(gpdpc)
 drop if fte == 0

 xtset ccode year
 global avars "fte gender gender_cs w_in_par long_tfr party2 left center gdppc polity pr"

foreach var of varlist $avars {
	gen Lag`var' = l.`var'
	}

 **** Year Trend dummies *****
 gen trend = 0
 replace trend = 1 if year >= 1900 & year < 1918
 replace trend = 2 if year >= 1918 & year < 1936
 replace trend = 3 if year >= 1936 & year < 1954
 replace trend = 4 if year >= 1954 & year <= 1970

 drop if missing(Lagfte)
 drop if year > 1970
 drop if country == "Australia" 
 drop if country == "Canada" 

 * Testing non-stationarity - Fisher Test for panel unit root using an augmented Dickey-Fuller test for unbalanced panel data
 xtfisher fte, trend l(0)
 xtfisher gdppc, trend l(1)
 xtfisher long_tfr, trend l(0)
 xtfisher polity, trend l(1)
 xtfisher wp_experience, trend l(0)
 xtfisher w_in_par, trend l(1)
 xtfisher sum, trend l(0)
 xtfisher suffrage, trend l(0)
 
 * Testing for heteroskedasticity, evidence of the existence of heteroskedasticity 
 xtreg fte gdppc long_tfr i.Lagparty2 Lagpolity Lagpr suffrage ilo_mem i.depression wp_experience Lagw_in_par, fe vce(robust)
 xttest3
 
 * Testing for serial correlation, evidence of the existence of serial correlation 
 xtserial fte gdppc long_tfr Lagleft Lagcenter Lagpolity ilo_mem depression wp_experience Lagw_in_par, output

 * Testing for random effects: Breusch-Pagan Langrange multiplier, evidence of significant variance accross countries - no substantial difference
 xtreg fte gdppc long_tfr i.Lagparty2 Lagpolity Lagpr suffrage ilo_mem i.depression wp_experience Lagw_in_par, fe
 estimates store fe
 xtreg fte gdppc long_tfr i.Lagparty2 Lagpolity Lagpr suffrage ilo_mem i.depression wp_experience Lagw_in_par, re
 estimates store re
 hausman fe re
 
 * Testing for endogeneity Durbin–Wu–Hausman test (augmented regression test) for endogeneity - no evidence for endogeneity
 xtreg Lagw_in_par gdppc Lagpolity Lagpr i.Lagparty2 ilo_mem depression wp_experience, fe vce(robust)
 predict Lagw_in_par_res1, res
 xtreg fte Lagw_in_par long_tfr i.Lagparty2 suffrage ilo_mem depression wp_experience Lagw_in_par_res1, fe vce(robust)
 test Lagw_in_par_res1
 
 xtreg Lagw_in_par gdppc Lagpolity wp_experience Lagpr long_tfr i.Lagparty2 ilo_mem depression, fe vce(robust)
 predict Lagw_in_par_res2, res
 xtreg fte Lagw_in_par long_tfr i.Lagparty2 ilo_mem depression Lagw_in_par_res2, fe vce(robust)
 test Lagw_in_par_res2
  
 xtreg Lagw_in_par Lagpolity depression wp_experience long_tfr i.Lagparty2 Lagpr ilo_mem, fe vce(robust)
 predict Lagw_in_par_res3, res
 xtreg fte Lagw_in_par long_tfr gdppc i.Lagparty2 Lagpr ilo_mem Lagw_in_par_res3, fe vce(robust)
 test Lagw_in_par_res3
 
 xtreg Lagw_in_par gdppc Lagpolity Lagpr i.Lagparty2 suffrage ilo_mem depression wp_experience, fe vce(robust)
 predict Lagw_in_par_res4, res
 xtreg fte Lagw_in_par long_tfr i.Lagparty2 suffrage ilo_mem depression wp_experience Lagw_in_par_res4, fe vce(robust)
 test Lagw_in_par_res4
 
 xtreg Lagw_in_par gdppc Lagpolity wp_experience long_tfr i.Lagparty2 Lagpr suffrage ilo_mem depression, fe vce(robust)
 predict Lagw_in_par_res5, res
 xtreg fte Lagw_in_par long_tfr i.Lagparty2 Lagpr suffrage ilo_mem depression Lagw_in_par_res5, fe vce(robust)
 test Lagw_in_par_res5
  
 xtreg Lagw_in_par suffrage Lagpolity depression wp_experience long_tfr i.Lagparty2 Lagpr ilo_mem, fe vce(robust)
 predict Lagw_in_par_res6, res
 xtreg fte Lagw_in_par long_tfr gdppc i.Lagparty2 Lagpr ilo_mem Lagw_in_par_res6, fe vce(robust)
 test Lagw_in_par_res6
  
 * Testing for multicollinearity, no evidence fo the multicolinearity problem - no substantial multicolinearity
 reg fte gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem depression wp_experience Lagw_in_par
 vif 
 reg fte gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem depression wp_experience sum
 vif 
 
 **** Table 3. Multivariate analysis: Extension of paid maternity leave, 1900-1970 **** 
 eststo clear
 eststo: xtreg fte Lagw_in_par wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression, fe vce(robust)
 estimates store fixed1
 eststo: xtreg fte sum wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression, fe vce(robust)
 estimates store fixed2
 eststo: xtpcse fte Lagw_in_par wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression i.ccode, pairwise correlation(ar1) np1
 estimates store pcse1
 eststo: xtpcse fte sum wp_experience gdppc long_tfr i.Lagparty2 Lagpr ilo_mem i.depression i.ccode, pairwise correlation(ar1) np1
 estimates store pcse2
 outreg2 [fixed1 fixed2 pcse1 pcse2] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\Women_sp.doc", replace

 **** Table 4. Robustness Checks: Extension of paid maternity leave, 1900-1970 **** 
 eststo: xtreg fte Lagw_in_par wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression, fe vce(jackknife)
 estimates store robust1
 eststo: xtpcse fte Lagfte Lagw_in_par wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression i.ccode, pairwise correlation(ar1) np1
 estimates store robust2
 eststo: xtpcse fte Lagw_in_par gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression War_Ind2post i.ccode, pairwise correlation(ar1) np1
 estimates store robust3
 eststo: xtpcse fte Lagw_in_par gdppc long_tfr i.Lagparty2 Lagpolity Lagpr ilo_mem i.depression War_Index2 i.ccode, pairwise correlation(ar1) np1
 estimates store robust4
 outreg2 [robust1 robust2 robust3 robust4] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\robust_check.doc", replace

 **** Appendix 4. Robustness check: suffrage control **** 
 xtreg d.fte l.fte l.gdppc d.gdppc l.long_tfr d.long_tfr l.left d.left l.center d.center l.polity d.polity l.pr d.pr l.suffrage d.suffrage l.ilo_mem d.ilo_mem l.depression d.depression l.wp_experience d.wp_experience l.w_in_par d.w_in_par, fe
 estimates store ecm1
 xtreg d.fte l.fte l.gdppc d.gdppc l.long_tfr d.long_tfr l.left d.left l.center d.center l.polity d.polity l.pr d.pr l.suffrage d.suffrage l.ilo_mem d.ilo_mem l.depression d.depression l.wp_experience d.wp_experience l.sum d.sum, fe
 estimates store ecm2
 outreg2 [ecm1 ecm2] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\ecm.doc", replace

 **** Appendix 5. Robustness check: trend controls **** 
 eststo clear
 eststo: xtreg fte Lagw_in_par wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr i.trend, fe vce(robust)
 estimates store fixed1
 eststo: xtreg fte sum wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr i.trend, fe vce(robust)
 estimates store fixed2
 eststo: xtpcse fte Lagw_in_par wp_experience i.ccode gdppc long_tfr i.Lagparty2 Lagpolity Lagpr i.trend i.ccode, pairwise correlation(ar1) np1
 estimates store pcse1
 eststo: xtpcse fte sum wp_experience gdppc long_tfr i.Lagparty2 Lagpolity Lagpr i.trend i.ccode, pairwise correlation(ar1) np1
 estimates store pcse2
 outreg2 [fixed1 fixed2 pcse1 pcse2] using "C:\Users\kson\Seafile\My Library\POSTDOC\Women_SP\robust_check_year.doc", replace